package com.guess.lolguessing.controller;


import com.guess.lolguessing.domain.dto.CommentDTO;
import com.guess.lolguessing.domain.queryPage.CommentPage;
import com.guess.lolguessing.domain.vo.CommentVO;
import com.guess.lolguessing.result.Result;
import com.guess.lolguessing.service.impl.CommentServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-10-18
 */
@RestController
@RequestMapping("/comment")
@RequiredArgsConstructor
@CrossOrigin(origins = {"http://localhost:8080", "http://172.24.0.1:8080"}) // 允许来自该源的请求
public class CommentController {

    private final CommentServiceImpl commentService;
    @PostMapping("submit")
    public Result submitComment(@RequestBody CommentDTO dto) {
        commentService.submitComment(dto);
        return Result.success();
    }

    @GetMapping("/comments")
    public CommentPage getComments(
            @RequestParam("matchId") Integer matchId,
            @RequestParam("playerId") Integer playerId,
            @RequestParam("page") Integer page) {
        System.out.println("page is " + page);
        return commentService.getComments(matchId, playerId, page);
    }

}
